/**
 * BoardAction.java 1.0 2007-5-6 下午11:16:46,创建 by yangfan
 */


package org.in4j.bbs.action;

import java.util.HashSet;

import org.in4j.bbs.model.Board;
import org.in4j.bbs.model.Topic;
import org.in4j.bbs.service.BoardService;
import org.in4j.bbs.service.TopicService;
import org.in4j.core.dao.support.Pagination;

/**
 *
 * @author yangfan
 * @version 1.0 2007-5-6 下午11:16:46,创建
 */
public class BoardAction extends AbstractAction
{
	private static final long serialVersionUID = 1L;

	private String boardName;
	private BoardService boardService;
	private TopicService topicService;
	private int pageNo = 1;
	final private int pageSize = 25;

	private Board board;
	private Pagination<Topic> topicsPagination;

	@Override
	public String execute() throws Exception
	{
		this.board = boardService.getBoardByName(boardName,true);
		if(board == null) return INDEX;
		board.setTopics(new HashSet<Topic>());
		this.topicsPagination = topicService.listTopicsByBoardId(board.getId(),pageNo,pageSize);
		return SUCCESS;
	}

	public Board getBoard()
	{
		return this.board;
	}

	public void setBoardName(String boardName)
	{
		this.boardName = boardName;
	}

	public void setBoardService(BoardService boardService)
	{
		this.boardService = boardService;
	}

	public Pagination<Topic> getTopicsPagination()
	{
		return topicsPagination;
	}

	public void setPageNo(int startIndex)
	{
		this.pageNo = startIndex;
	}

	public void setTopicService(TopicService topicService)
	{
		this.topicService = topicService;
	}
}
